package com.gaofans.vertx.boot.web.template;

import io.vertx.core.Vertx;
import io.vertx.ext.web.common.template.TemplateEngine;
import io.vertx.ext.web.templ.freemarker.FreeMarkerTemplateEngine;

/**
 * freemarker
 * @author GaoFans
 */
public class FreeMarkerEngineFactory implements TemplateEngineFactory {


    private Vertx vertx;

    private int maxCacheSize = FreeMarkerTemplateEngine.DEFAULT_MAX_CACHE_SIZE;

    public FreeMarkerEngineFactory(Vertx vertx) {
        this.vertx = vertx;
    }

    public FreeMarkerEngineFactory(Vertx vertx, int maxCacheSize) {
        this.vertx = vertx;
        this.maxCacheSize = maxCacheSize;
    }

    @Override
    public TemplateEngine create() {
        return FreeMarkerTemplateEngine.create(vertx).setMaxCacheSize(this.maxCacheSize);
    }
}
